import SwiftUI
import Kingfisher

struct FoodItemHStackView: View {
    var model: FoodItemModel
    
    var body: some View {
        HStack(spacing: 12.0) {
            KFImage(URL(string: model.imgUrl))
                .placeholder({
                    WebImageLoadingView()
                })
                .onFailureImage(.iconPlaceholderFood)
                .resizable()
                .frame(width: 76.0, height: 76.0)
                .aspectRatio(contentMode: .fill)
                .clipShape(RoundedRectangle(cornerRadius: 12.0))
            VStack(alignment: .leading, spacing: 8.0) {
                Text(model.title)
                    .font(.alibabaPuHuiTi(size: 16.0, weight: .regular))
                    .foregroundStyle(.fs000000)
                    .lineLimit(1)
                
                HStack(spacing: 4.0) {
                    ForEach(model.tags, id: \.self) { tag in
                        TagView(tag: tag)
                    }
                }
                
                HStack(alignment: .firstTextBaseline, spacing: 2.0) {
                    Text(model.price)
                        .font(.inter(size: 18.0, weight: .extraBold))
                        .lineLimit(1)
                }
                .foregroundStyle(Color.fsFB5D3B)
            }
            Spacer()
        }
        .frame(maxWidth: .infinity)
        .padding(12.0)
        .background(
            RoundedRectangle(cornerRadius: 20.0)
                .fill(Color.fsFFFFFF)
        )
    }
}
